package com.ruoyi.web.invest.asset.feedback.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.invest.asset.feedback.domain.FeedBack;
import com.ruoyi.web.invest.asset.feedback.service.IFeedBackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 阶段性反馈Controller
 *
 * @author houxuzhong
 * @date 2021-08-26
 */
@RestController
@RequestMapping("/invest/asset/feedback")
public class FeedBackController extends BaseController
{
    @Autowired
    private IFeedBackService feedBackService;

    /**
     * 查询阶段性反馈列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FeedBack feedBack)
    {
        startPage();
        List<FeedBack> list = feedBackService.selectFeedBackList(feedBack);
        return getDataTable(list);
    }

    /**
     * 导出阶段性反馈列表
     */
    @Log(title = "阶段性反馈", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FeedBack feedBack)
    {
        List<FeedBack> list = feedBackService.selectFeedBackList(feedBack);
        ExcelUtil<FeedBack> util = new ExcelUtil<FeedBack>(FeedBack.class);
        return util.exportExcel(list, "阶段性反馈数据");
    }

    /**
     * 获取阶段性反馈详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(feedBackService.selectFeedBackById(id));
    }

    /**
     * 新增阶段性反馈
     */
    @Log(title = "阶段性反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeedBack feedBack)
    {
        return toAjax(feedBackService.insertFeedBack(feedBack));
    }

    /**
     * 修改阶段性反馈
     */
    @Log(title = "阶段性反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeedBack feedBack)
    {
        return toAjax(feedBackService.updateFeedBack(feedBack));
    }

    /**
     * 删除阶段性反馈
     */
    @Log(title = "阶段性反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(feedBackService.deleteFeedBackByIds(ids));
    }
}
